<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>注册 - {:cms('title')}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">  
<link rel="stylesheet" href="*ADMIN*/layui/css/layui.css">
<link rel="stylesheet" href="*PC*/css/login.css">
<script src="*ADMIN*/js/jquery-3.4.1.min.js"></script>
<script src="*ADMIN*/layui/layui.js"></script>
</head>
<body>
<div class="header">
<form class="center  layui-form" onsubmit="return false" autocomplete="off">
  <div class="form-inner">
    <h2>注册</h2>
    <div class="input-wrapper">
      <label for="login-username">你的邮箱</label>
      <div class="input-group"><span class="icon">
          <i class="layui-icon" style="font-size: 25px; color: #FFF;">&#xe628;</i>  
          </span>
        <input type="text" id="usermail" required  lay-verify="required" name="usermail" data-lpignore="true"/>
      </div>
    </div>
	{if condition="cms('regtxm') eq 1"}
    <div class="input-wrapper">
      <label for="login-username">图形码</label>
      <div class="input-group">
      	  <span class="icon">
             <i class="layui-icon" style="font-size: 25px; color: #FFF;">&#xe665;</i>  
          </span>
		<input type="text" placeholder="图形码" required  lay-verify="required"  id="captcha"	name="yzm" maxlength="4" autocomplete="off" required class="layui-required"/>
        <img id="captchaPic" class="yzms imgcode" src="/extend/yzm/code.php" onClick="this.src='/extend/yzm/code.php?nocache='+Math.random()" style="cursor:hand" alt="点击换一张"/>
      </div>
    </div>
	{/if}
	{if condition="cms('regmail') eq 1"}
    <div class="input-wrapper">
      <label for="login-username">验证码</label>
      <div class="input-group">
      	  <span class="icon">
             <i class="layui-icon" style="font-size: 25px; color: #FFF;">&#xe665;</i>  
          </span>
        <input type="text" required  lay-verify="required" placeholder="邮箱验证码"  name="code"  maxlength="6" data-lpignore="true"/>
          <button class="yzm" id="sendRegCode">
            获取验证码
          </button>
      </div>
    </div>
    {/if}
    <div class="input-wrapper">
      <label for="login-password">密码</label>
      <div class="input-group"><span class="icon">
      	<i class="layui-icon" style="font-size: 25px; color: #FFF;">&#xe673;</i>  
          </span>
        <input type="password" name="password" id="login-password"  required  lay-verify="required" data-lpignore="true"/>
      </div>
    </div>
    <div class="btn-group">
      <button class="btn btn--primary" lay-submit lay-filter="homereg">注册</button><a class="btn--text" href="/">返回首页</a> <a class="btn--text" href="*URL*/log.html">返回登录</a>
    </div>
  </div>
</form>
</div>
<div class="footer">
<p>Powered by <a href="https://www.115cms.com" target="_blank" style="color: #e4e2e2;">网家教育资讯管理系统</a> © 22020  版权所有</p>
</div>
<!--系统预留插件钩子请保留找注册页面-->
{:h('regpc')}
</body>
</html>
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
form.on('submit(homereg)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('/index.php/api/api/homereg.html',param,function(data){
      if(data.code == 200){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          $(document).ready(function(){
             $("#loginmain").show();
             $("#regmain").hide();
              location.href = '*URL*/log.html';
          });
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
});
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
     jq('#sendRegCode').click(function() {
    var obj = $(this);
    var options = {
        seconds: 60
        , type: 'REG'
    };
     var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); 
     var mail = $("#usermail").val();
  　　if(mail == ""){ 
  　　　layer.msg('邮箱必填');
  　　　　return false;
  　　}else if(!reg.test(mail)){ 
 　　layer.msg('邮箱格式不对');
 　　　　return false;
 　　}
 　　loading = layer.load(0, {
         shade: [0.2, '#000']
    });
    jq.getJSON('/index.php/api/mail/email.html?mail='+mail, function(data) {
        if (data.code == 200) {
            layer.close(loading);
            layer.msg(data.msg, {
            icon: 1,
            time: 1000
        }, function() {
             countDown(60, obj);
        });
    } 
  });
 });
});
function countDown(seconds, obj) {
    if (seconds > 1) {
        seconds--;
        $(obj).attr('disabled', true).html(seconds + "秒");//禁用按钮
        setTimeout(function () {
            countDown(seconds, obj);
        }, 1000);
    } else {
        $(obj).attr('disabled', false).html("获取验证码");//启用按钮
    }
}
</script>